import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { OrderLogEntity } from '../../entity/log';
import { OrderLogService } from '../../service/log';
import { BaseSysUserEntity } from '../../../base/entity/sys/user';
import { OrderInfoEntity } from '../../entity/info';

/**
 * 订单日志
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: OrderLogEntity,
  service: OrderLogService,
  pageQueryOp: {
    join: [
      {
        entity: OrderInfoEntity,
        alias: 'b',
        condition: 'a.orderId = b.id',
        type: 'leftJoin',
      },
      {
        entity: BaseSysUserEntity,
        alias: 'c',
        condition: 'a.operatorType = 1 AND a.operatorId = c.id',
        type: 'leftJoin',
      },
    ],
    select: ['a.*', 'b.orderNumber', 'c.username as operatorName'],
  },
})
export class AdminOrderLogController extends BaseController {
  @Inject()
  orderLogService: OrderLogService;
}
